clear all; close all; clc;
Fd=44.2e6/4; Td=1/Fd;
tmax=0.001; t=0:Td:tmax;

N_PRN=511; T_PRN=0.001;
PRN=sign(randn(1,N_PRN));
ind_h=fix(mod(t/T_PRN,1)*N_PRN)+1;
h=PRN(ind_h);

A=2;
f0=3e6;
phi=pi/4;

u=A*h.*cos(2*pi*f0*t+phi);
dt=-1.5:0.1:1.5;
dt=dt*(T_PRN/N_PRN);


for i=1:length(dt)
    ind_h=fix(mod((t+dt(i))/T_PRN,1)*N_PRN)+1;
h=PRN(ind_h);

S=h.*cos(2*pi*f0*t);
I(i)=S*u';
end


plot(dt,I)
grid on